Skip to content

Reimplement 1 BuildingsState function at 100% from #234 - #552

Open
gynt wants to merge 8 commits into
sourcehold:mainfrom
gynt:reimpl/pr234-matched
Open

gynt wants to merge 8 commits into
sourcehold:mainfrom
gynt:reimpl/pr234-matched

Conversation

@gynt

@gynt gynt commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

This PR carries the finished part of draft PR #234 (reimpl/BuildingsState): the one function of its four that is at 100%. No function with register-allocation-only differences qualified (see below).

Measured on origin/main (40cbb1c, re-measured after merging 592a17d): I built the DLL with exactly this file in the build list, with the struct resolvers and its function resolver switched on, then ran reccmp. The file is taken unchanged from #234, and clang-format makes no changes to it.

Function Address raw % normalized % Status
BuildingsState::initBuildingCosts 0x00419780 94.7 92.3 Reimplemented (counted: only the loop-end address 0x5C2A6C, one past BuildingCost, is labelled differently in ours)

The only line reccmp marks is the loop bound: the original's cmp eax, <RenderingDefinedData instance> against ours, cmp eax, cached+4. Both are the same address 0x5C2A6C, which reccmp symbolizes differently. This is main's existing "counted" case, worded the same way as the three functions already counted for it.

Header changes: none. /GL and function-visibility entries: none needed.

Left in #234 (more than register allocation differs):

  • giveBackResourceForDestroyedBuilding (90.6): an imul/add pair runs in a different order, and the original re-reads the building type with movsx where ours reloads a spilled copy.
  • determineBuildingEntranceFromCustomArea (98.2): a tile sum is reassociated.
  • setupBuildingData (87.0): the field addresses are hoisted and spilled in a different place.

Overlap with open PRs: none outside #234 itself.

Style pass (style: commit, following the current REIMPLEMENTATION_STYLE_GUIDE.md on main):

  • the five BuildingCost columns are indexed with BuildingCostResource (BCR_WOOD ... BCR_GOLD) instead of 0-4;
  • namespace closing comments.

I re-measured with a full build and reccmp: still 94.7/92.3, and the loop-end symbol is still the only difference.

There is one commit for the function, with its status line.

Draft PR #234 stays open for the remaining three functions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp

gynt and others added 5 commits December 4, 2026 15:17
…y the loop-end symbol differs)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
BuildingCostResource (BCR_WOOD..BCR_GOLD) instead of the column numbers 0-4, and namespace closing comments. Re-measured on 40cbb1c with a full build and reccmp: 94.7/92.3; only the loop-end symbol still differs, as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Drop the comment that restates the loop. Re-measured on 592a17d with a full build and reccmp: 94.7/92.3, still only the loop-end symbol differs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Comment thread status/addresses-SHC-3BB0A8C1.txt Outdated
SHC_3BB0A8C1_0x004196D0 | 100.0% | Reimplemented

SHC_3BB0A8C1_0x00419780 | 0.0% | Pending
SHC_3BB0A8C1_0x00419780 | 100.0% | Reimplemented (counted: only the loop-end symbol differs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

@gynt gynt Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reccmp scores it 94.7. The only differing instruction is the loop-end compare: the original cmp eax, 0x5C2A6C points one past the BuildingCost array, and reccmp labels that address RenderingDefinedData (the next global), while ours gets a different label. Everything else is identical. The remark now says this precisely, in main's counted: form (0ad637c).

gynt and others added 3 commits December 5, 2026 01:53
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The only differing instruction is the loop-end compare: the original's
cmp eax, 0x5C2A6C points one past BuildingCost, which reccmp labels
RenderingDefinedData, while the build's operand gets another symbol name.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants